/**
 * Created by huguowei on 2017/5/6.
 */
function formatFileSize (fileSize, idx = 0) {
  const units = ['B', 'KB', 'MB', 'GB']
  if (fileSize < 1024 || idx === units.length - 1) {
    return fileSize.toFixed(1) + units[idx]
  }
  const index = idx + 1
  return formatFileSize(fileSize / 1024, index)
}

export default formatFileSize
